/*
 * JaCoLiB
 * Copyright (C) 2008 Alessandro Serra
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package it.gashale.jacolib.rpc;

import it.gashale.jacolib.core.JacolibError;

public class RPCClient {
	private RPCClientStub client_stub;
	
	protected RPCClient(RPCClientStub stub) {
		client_stub=stub;
	}
	public RPCClientStub getClientStub() {
		return client_stub;
	}
	
	/*
	 * exec
	 */
	public Object exec(String method) throws JacolibError {
		RPCRequest request=new RPCRequest(method);
		RPCResponse res=client_stub.exec(request);
		return res.getResponse();
	}
	public Object exec(String method, Object arg) throws JacolibError {
		RPCRequest request=new RPCRequest(method);
		request.addParameter(arg);
		RPCResponse res=client_stub.exec(request);
		return res.getResponse();
	}
	public Object exec(String method, Object arg1, Object arg2) throws JacolibError {
		RPCRequest request=new RPCRequest(method);
		request.addParameter(arg1);
		request.addParameter(arg2);
		RPCResponse res=client_stub.exec(request);
		return res.getResponse();
	}
	/*
	 * quit
	 */
	public void quit() throws JacolibError {
		client_stub.quit();
	}
	protected void quit_p() {
		client_stub.quit_p();
		client_stub=null;
	}
}


